package vn.com.bookstore.model;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;

import vn.com.bookstore.ObjectStore;

import com.google.gson.Gson;

@SuppressWarnings("serial")
public class Store extends ObjectStore{
	public static final String TAG = "store";
	
	public int id = -1;
	private String name = "";
	public String desc = "";
	public String image = "";
	public ArrayList<Book> books;
	
	public Store() {
		id = -1;
		books = new ArrayList<Book>();
	}
	
	public static Store createDataSample(){
		Store cat = new Store();
		for(int i=0;i<15;i++){
			Book book = Book.createDataSample(i);
			cat.books.add(book);
		}
		cat.name = "New";
		cat.image = "";
		return cat;
	}
	
	public static Store parseGson(String json){
		Gson gson = new Gson();
		Store category = (Store)gson.fromJson(json, Store.class);
		return category;
	}
	
	public String getName() {
		try {
			return new String(name.getBytes("utf-8"),"utf-8");
		} catch (UnsupportedEncodingException e) {
		}
		return name;
	}
}
